//
//  baseCommonMethod.h
//  baseVC
//
//  Created by 陶磊 on 2019/12/16.
//  Copyright © 2019 QHT. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

//1像素
#define ONEPIEXLHEIGHT (1.0/[UIScreen mainScreen].scale)

#define ALLCHARACTERANDNUMBER @"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"

#define ALLCHARACTER @"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"

#define NOMOREDATA @"已无更多数据"

NS_ASSUME_NONNULL_BEGIN

@interface baseCommonMethod : NSObject

/** version */
+ (NSString *)appVersionString;

/** build */
+ (NSString *)appBuildString;

/** version(build) */
+ (NSString *)appVersionAndBuildString;

//UUID,IDFV,用于应用的开发商(Vendor)唯一标识一台设备的ID。根据包名的前两部分算出。同一台设备，如果有相同开发商多个app,号码一样。
+ (NSString*)getUUID;

#pragma mark -- 请求参数

//每个接口必传参数
+ (NSMutableDictionary *)commonParameters;

//登陆后必传参数 (添加Uid time access_key)
+ (NSMutableDictionary *)getAuthParmersPrefix;

//登陆后增加的参数 添加了 uid time accessKey
+ (NSMutableDictionary *)getUidAndTimeWithAccessKey;

//H5拼接参数
+ (NSString *)urlStringAddParameter:(NSString *)urlStr;

#pragma mark -- end

//JPush RegistrationID
+ (NSString *)getRegistrationID;

// platform 区分安卓 ios
+ (NSString *)getPlatform;

//屏幕宽度
+ (CGFloat)getScreenWidth;

//屏幕高度
+ (CGFloat)getScreenHeight;

//验证身份证
+ (BOOL)validateNumber:(NSString*)number;


/**
 只保留数字，去掉其他字符

 @param str str description
 @return return value description
 */
+ (NSString *)getOnlyNum:(NSString *)str;

#pragma mark -- 限制输入 在UITextFieldDelegate中使用
/** 验证输入字符串是否符合限制字符串 */
+ (BOOL)validateString:(NSString *)originalString limitString:(NSString *)limitString;

/** 限制输入位数 maxLength最大长度。在UITextFieldDelegate中使用 */
+ (BOOL)validateTextField:(UITextField *)textField
                    range:(NSRange)range
                   string:(NSString *)string
                maxLength:(NSInteger)maxLength;

/** 验证textfield输入长度,只能输入数字 */
+ (BOOL)validateOnlyNumberTextField:(UITextField *)textField
                              range:(NSRange)range
                             string:(NSString *)string
                          maxLength:(NSInteger)maxLength;

/** 验证textfield输入长度,只能输入字母或数字 */
+ (BOOL)validateCharacterORNumberTextField:(UITextField *)textField
                                     range:(NSRange)range
                                    string:(NSString *)string
                                 maxLength:(NSInteger)maxLength;

/** 验证身份证，只能输入数字和Xx，并且长度小于18位。在UITextFieldDelegate中使用 */
+ (BOOL)validateIDNumberTextField:(UITextField *)textField
                            range:(NSRange)range
                           string:(NSString *)string;

//判断用户名是否为空
+ (BOOL)isUserNameKong :(NSString *)String;

//判断手机号是否为空
+ (BOOL)isPhoneNumberKong :(NSString *)textFieldStr;

//验证手机号
+ (BOOL)isPhoneNumber:(NSString *)strPhone;

//判断密码是否为空
+ (BOOL)isPasswordKong :(NSString *)String;

//检查密码是否有效
+ (BOOL)isValidPassword:(NSString*)password;

//判断验证码是否为空
+ (BOOL)isCheckNumberKong:(NSString *)String;
//判断字符串是否为空
+ (BOOL)isCheckStringKong:(NSString *)String msg:(NSString *)msg;
//判断是否是数字
+ (BOOL)isNumber:(NSString *)str;
//设置数字富文本样式
+ (NSMutableAttributedString *)getStringSignText:(NSString *)string;
//判断应用在后台
+ (BOOL)runningInBackground;
//判断应用在前台
+ (BOOL)runningInForeground;

//弹出默认UIAlertController
+ (void)alertController:(NSString *)title
                message:(NSString *)message
                     VC:(UIViewController *)VC
        eventOneHandler:(void (^)(UIAlertAction *msgString))eventOneHandler
        eventTwoHandler:(void (^)(UIAlertAction *msgString))eventTwoHandler
            alertOneStr:(NSString *)alertOneStr
            alertTwoStr:(NSString *)alertTwoStr;

//十六进制颜色值转换成color
+ (UIColor *)getColor:(NSString *)hexColor;

/**
 *float类型数字转换成"万元"
 */
+ (NSString *)updatePrice:(float)floatNumber;

/**
 *将拍单状态转换为对应字符串
 */
+ (NSString *)changeStateToString:(NSInteger)state;

/**
 *毫秒转成"时:分:秒"
 */
+ (NSString *)changeTimeInterval:(long long)millisecond;

/**
 *毫秒转成"分:秒"
 */
+ (NSString *)changeTimeIntervalToMinSec:(long long)millisecond;

/**
 *计算剩余时间
 * state状态
 * sceneStartTime场次开始时间
 * biddingStartTime拍单开始时间
 * actElapsedTime实际拍卖时间
 * estElapsedTime预估拍卖时间
 * return long long remainTime
 */
/*
+ (long long)calRemainTimeOrderState:(NSInteger)state
                      sceneStartTime:(long long)sceneStartTime
                    biddingStartTime:(long long)biddingStartTime
                      actElapsedTime:(long long)actElapsedTime
                      estElapsedTime:(long long)estElapsedTime;
*/

//cell上button找到cell
+ (id)findMyCell:(Class)cellClass button:(UIButton *)btn;

/** 获得dealerID */
+ (NSInteger)dealerID;

/** 获得dealerID字符串 */
+ (NSString *)dealerIDStr;

/** 判断服务器返回字段数值是否为null */
+ (BOOL)isNull:(id)obj;

+ (BOOL)isNull:(id)obj isClass:(Class)isClass;

+ (BOOL)isNull:(NSDictionary *)dic key:(NSString *)key;

+ (BOOL)isNull:(NSDictionary *)dic key:(NSString *)key isClass:(Class)isClass;

/*
 * 返回当前值或者nil
 * NSNumber : 123 true false null
 * NSString : "123"
 * NSDictionary : {}
 * NSArray : []
 */
+ (id)checkNull:(id)obj;

+ (id)checkNull:(id)obj isClass:(Class)isClass;

+ (id)dictionary:(NSDictionary *)dictionary objectForKey:(NSString *)key;

/**
 * 请求header中cookie增加审核字段
 */
+ (void)requestAddCookieAuditing;

/**
 * 删除header中cookie增加的审核字段
 */
+ (void)requestDeleteCookieAuditing;

/**
 * 先删除header中的cookie，再根据auditing状态设置cookie
 */
+ (void)cookieSetupWithAuditing;

//跳转webView(无交互页面)
//+ (void)pushWebviewVC:(NSString *)titleStr UrlStr:(NSString *)UrlStr VC:(UIViewController *)VC;

/**
 * UIColor转为UIimage
 */
+ (UIImage *)imageWithColor:(UIColor *)color;

//获得公钥
//+ (void)getPublicKeyFromNetWorking:(void (^)(NSString *str))resultString;

//查询弹框
//+ (void)alertTanSeacher:(NSString *)priceSeacherStr alertTanView:(AlertTextAndButtonview *)alertTanView;

//充值弹框
//+ (void)alertViewTanisOrPayVC:(AlertOnlyTextView *)alertView;

 //富文本
+ (NSMutableAttributedString *)activityLabdataString:(NSString *)string range:(NSRange)rangeMake textColor:(UIColor *)textColor font:(NSInteger)font;

//查询配置表(最外层字段)
+ (id)getConfigDataFromString:(NSString *)string;

//toast
+ (void)showToast:(NSString *)toastString;

//暂无数据
+ (void)NoDateWarnNoDataView:(UIView *)dataView addToSelfView:(UIView *)viewSelf ImgString:(NSString *)imgString titString:(NSString *)titString;

/**
 获得1像素高度
 @return 1像素高度
 */
+ (CGFloat)onePixel;

#pragma mark -- UITableViewCell
/**
 tableView注册nib 常见设置
 @param tableView tableView description
 @param nibStr nibStr description
 */
+ (void)tableView:(UITableView *)tableView registerNib:(NSString *)nibStr;


+ (void)tableViewSetting:(UITableView *)tableView registerNib:(NSString *)nibStr;

/**
 返回空UITableViewCell
 @param tableView
 @return
 */
+ (UITableViewCell *)defaultTableViewCell:(UITableView *)tableView;

#pragma mark -- custom constraint
/**
 在baseView与subView之间增加上下左右四个0的约束,方法必须在addSubview之后
 @param baseView 基础view
 @param subView
 */
+ (void)constraintBaseView:(UIView *)baseView subView:(UIView *)subView;

#pragma mark -- formatNSString
+ (NSString *)formatStr:(NSString *)str;

//是否登录
+ (BOOL)isLogin;

//去掉头尾回车符
+ (NSString *)getPublicKeyCertString:(NSString *)certDataString;

+ (CGFloat)labHight:(UIFont* )aFont width:(float )aWidth text:(NSString* )aStr;

+ (CGFloat)labWidth:(UIFont* )aFont hight:(float )aHeight text:(NSString* )aStr;

//获取图片文件名
+(NSString *)gettimeFileName;

//获取当前时间
+(NSString *)getMonth;

/**
 获取这种格式时间 2017-12-5 09:58:21
 */
+ (NSString *)formattedDate;

// 获取这种格式时间 2017-12-5 09:58:21
+ (NSString *)formattedDate:(NSString *)str;

//获取时间格式 2018-03-15 09:32
+ (NSString *)formattedDateyyyyMMddHHmm:(NSString *)str;


/**
// 获取当前时间，这种格式 2017-12-5
 */
+ (NSString *)formattedDateYMD;


/**
 获取今天日期，这种格式 2017125
 
 @return yyyyMMdd
 */
+ (NSString *)formattedDateyyyyMMdd;

// 获取这种格式时间 2017-12-5
+ (NSString *)formattedDateYMD:(NSString *)str;

/**
 处理时间格式 将2018-01-01 15:39格式处理为2018-01-01
 */
+ (NSString *)interceptString:(NSString *)str;

/**
 拼接成新字符串
 */
+ (NSString *)interceptString:(NSString *)startStr withEndString:(NSString *)endStr;

// 获取时间戳
+ (NSString *)systemTimestamp;

// 时间戳(毫秒)+3位随机数
+ (NSString *)systemTimestampWithThreeNumber;

// NSDate转周几
+ (NSString *)dateToWeek:(NSDate *)date;

//转换成json字符串
+ (NSString *)getJsonStringData:(id)data;

//Json字符串转化成id类型数据
+ (id)getDataFromJsonStr:(NSString *)jsonString;

#pragma mark -- json
/**
 json to BOOL, 其他返回NO
 
 @param obj
 @return BOOL
 */
+ (BOOL)toBOOL:(NSObject *)obj;

/**
 json to NSInteger, string转为integer, 其他返回0
 
 @param obj
 @return NSInteger
 */
+ (NSInteger)toInteger:(NSObject *)obj;

/**
 json to NSString, integer转为string, 其他返回nil
 
 @param obj
 @return NSString
 */
+ (NSString *)toString:(NSObject *)obj;

/**
 json to NSArray
 
 @param obj
 @return NSArray
 */
+ (NSArray *)toArray:(NSObject *)obj;

/**
 json to NSDictionary
 
 @param obj
 @return NSDictionary
 */
+ (NSDictionary *)toDictionary:(NSObject *)obj;

#pragma mark -- storyboard
/**
 getVC use storyboard name and storyboard id

 @param name name description
 @param identifier identifier description
 @return return value description
 */
+ (__kindof UIViewController *)instantiateVCWithName:(NSString *)name ID:(NSString *)identifier;

#pragma mark -- 价格转换
+ (NSString *)priceAddSymbol:(CGFloat)price WithThousands:(BOOL)isThousand;

#pragma mark -- 拼接图片地址
+ (NSURL *)urlWithStringAddHeader:(NSString *)str;

//街区第一针
+ (UIImage*)getVideoPreViewImage:(NSURL *)path;

#pragma mark -- 语音识别
/**
 语音识别

 @param text
 @return
 */
+ (NSArray<NSString *> *)getNumberFromString:(NSString *)text;

/**
 比较两个float类型是否相同

 @param number1 number1 description
 @param number2 number2 description
 @return return value description
 */
+ (BOOL)isFloatEqual:(CGFloat)number1 number:(CGFloat)number2;

//字符转字典
+ (NSDictionary *)dictionaryWithJsonString:(NSString *)jsonString;

/** 金额四舍五入*/
+ (NSString *)decimalwithFormat:(CGFloat)floatV;

// NSDictionary 转 jsonString
+ (NSString *)convertNSDictionaryToJsonString:(NSDictionary *)json;
/** 比较时间大小*/
+ (int)compareOneDay:(NSDate*)oneDay withAnotherDay:(NSDate*)anotherDay;

@end

NS_ASSUME_NONNULL_END
